import record
import analisadorWave
import wave

rec1 = record.Record('/dev/dsp')
rec2 = record.Record('/dev/dsp1')

def disparaThreads():
	rec1.gravar()
	rec2.gravar()

def paraThreads():
	rec1.parar()
	rec2.parar()

def armazenaWaves():
	rec1.save2wave('rec1.wav')
	rec2.save2wave('rec2.wav')

def analisaWaves():
	w1 = analisadorWave(wave.open('rec1.wav'))
	w2 = analisadorWave(wave.open('rec2.wav'))
	print "Wave 1:"
	print "Maior amostra: %s" % w1.indiceMaior
	print "Intensidade: %s" % w1.listaAmostras[w1.indiceMaior]
	print "Instante em que ocorre: %s" % w1.segundoMaiorAmostra()
	print "\nWave 2:"
	print "Maior amostra: %s" % w2.indiceMaior
	print "Intensidade: %s" % w2.listaAmostras[w2.indiceMaior]
	print "Instante em que ocorre: %s" % w2.segundoMaiorAmostra()
	


###########################
###		EXECUCOES		###
disparaThreads()
raw_input("ENTER para parar as threads...")
paraThreads()
armazenaWaves()
#analisaWaves()

